package com.itheima.d6_object_stream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Arrays;

/*
  目标：掌握对象字节输出流的使用：序列化对象。
 */
public class Test1ObjectOutputStream {
    public static void main(String[] args) throws Exception {
        FileOutputStream fs = new FileOutputStream("a.txt");
        ObjectOutputStream os = new ObjectOutputStream(fs);
        ArrayList<User> users = new ArrayList<>();

        User user = new User("绫波丽", 12,"开0号机");
        User user1 = new User("明日香", 12,"开2号机");
     users.add(user);
     users.add(user1);

       os.writeObject(users);
       os.close();
    }

}
